//
//  MineDownloadCell.m
//  copyrightTrading
//
//  Created by 郭子一 on 2020/10/6.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MineDownloadCell.h"

@interface MineDownloadCell ()
@property (nonatomic, strong) UIImageView *img;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *middleLab;
@end

@implementation MineDownloadCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = RGB_VALUE(0xF5F5F5);
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.img = [[UIImageView alloc] init];
    self.img.layer.masksToBounds = YES;
    self.img.layer.cornerRadius = 10;
    self.img.backgroundColor = UIColor.cyanColor;
    [self.contentView addSubview:self.img];
    [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(20);
        make.width.mas_equalTo(140);
        make.height.mas_equalTo(90);
    }];
    
    self.titleLab = [UILabel new];
    self.titleLab.text = @"汽车高清宣传片";
    self.titleLab.font = JSS_MEDIUM_FONT(17);
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.img.mas_top);
        make.left.equalTo(self.img.mas_right).offset(13);
        make.right.offset(-20);
        make.height.mas_equalTo(24);
    }];
    
    self.middleLab = [UILabel new];
    self.middleLab.text = @"下载日期：2020-09-20\n类别：视频商务\n大小：3.2M\n格式：AE";
    self.middleLab.font = JSS_MEDIUM_FONT(10);
    self.middleLab.textColor = RGB_VALUE(0x848484);
    self.middleLab.numberOfLines = 0;
    [self.contentView addSubview:self.middleLab];
    [self.middleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLab.mas_bottom).offset(1);
        make.left.equalTo(self.titleLab.mas_left);
        make.right.offset(-85);
        make.height.mas_equalTo(56);
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = RGB_VALUE(0xDBDBDB);
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(22);
        make.right.offset(-22);
        make.height.mas_equalTo(1);
        make.bottom.offset(0);
    }];
}

- (void)setModel:(HWDownloadModel *)model
{
    _model = model;
    [self.img m_setImageWithUrlString:model.thumb placeholder:@"placeholderImg"];
    self.titleLab.text = model.fileName;
    self.middleLab.text = [NSString stringWithFormat:@"下载日期：%@\n类别：%@\n大小：%@\n格式：%@",model.dowmLoadDate,model.sortName,model.size,model.suffix];
}

@end
